home *** CD-ROM | disk | FTP | other *** search
- on assignSound whichSound, volumeDesired
- global oStoryteller, oPuppeteer, gSoundPath, gAmberPath, gHDsounds, gSoundPath2
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- set soundBank to getProp(the lsForegroundData of oPuppeteer, #soundBank)
- set freeChannel to #none
- repeat with i = 1 to count(soundChannels)
- set thisChannel to getAt(soundChannels, i)
- if getProp(thisChannel, #sndType) = #none then
- set freeChannel to i
- exit repeat
- end if
- end repeat
- if freeChannel = #none then
- repeat with i = 1 to count(soundChannels)
- set thisChannel to getAt(soundChannels, i)
- if getProp(thisChannel, #sndType) = #effect then
- if soundBusy(i) = 0 then
- set freeChannel to i
- exit repeat
- end if
- end if
- end repeat
- end if
- if freeChannel <> #none then
- if not integerp(volumeDesired) then
- set volumeDesired to 255
- end if
- set volumeTweaks to getaProp(the lsForegroundData of oPuppeteer, #soundVolTweaks)
- if listp(volumeTweaks) then
- set volAdjust to getaProp(volumeTweaks, whichSound)
- if not voidp(volAdjust) then
- set volumeDesired to volumeDesired * volAdjust
- end if
- else
- alert("Sorry, I couldn't find the #soundVolTweaks list in the foreground-data.. here's what I got:")
- put volumeTweaks
- end if
- set the volume of sound freeChannel to volumeDesired
- set soundCast to getProp(soundBank, whichSound)
- if voidp(soundCast) then
- return #badSound
- end if
- if listp(soundCast) then
- set soundCast to getAt(soundCast, random(count(soundCast)))
- end if
- if integerp(soundCast) then
- puppetSound(freeChannel, soundCast)
- end if
- if stringp(soundCast) then
- if getPos(gHDsounds, soundCast) = 0 then
- sound playFile freeChannel, gSoundPath2 & soundCast
- else
- sound playFile freeChannel, gSoundPath & soundCast
- end if
- end if
- end if
- return freeChannel
- end
-
- on setLoop whichSound, volumeDesired
- global oStoryteller, oPuppeteer
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- if voidp(volumeDesired) then
- set volumeDesired to 255
- end if
- set foundIt to 0
- repeat with i = 1 to count(soundChannels)
- set channelData to getAt(soundChannels, i)
- if getProp(channelData, #sndName) = whichSound then
- set volumeTweaks to getaProp(the lsForegroundData of oPuppeteer, #soundVolTweaks)
- if listp(volumeTweaks) then
- set volAdjust to getaProp(volumeTweaks, whichSound)
- if not voidp(volAdjust) then
- set volumeDesired to volumeDesired * volAdjust
- end if
- else
- alert("Sorry, I couldn't find the #soundVolTweaks list in the foreground-data.. here's what I got:")
- put volumeTweaks
- end if
- setProp(channelData, #volume, volumeDesired)
- set the volume of sound getPropAt(soundChannels, i) to getProp(channelData, #volume)
- set foundIt to 1
- end if
- end repeat
- if foundIt = 0 then
- set foundChannel to assignSound(whichSound, volumeDesired)
- if foundChannel = #none then
- put "setLoop(" & whichSound & "): Sorry, there are no free sound channels at this time."
- reportSounds()
- exit
- end if
- if foundChannel = #badSound then
- beep()
- put "Sorry, there's no such sound as #" & whichSound
- exit
- end if
- set channelData to getProp(soundChannels, foundChannel)
- setProp(channelData, #sndType, #loop)
- setProp(channelData, #sndName, whichSound)
- setProp(channelData, #volume, volumeDesired)
- end if
- end
-
- on endLoop whichSound
- global oStoryteller
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- repeat with i = 1 to count(soundChannels)
- set channelData to getAt(soundChannels, i)
- if getProp(channelData, #sndName) = whichSound then
- set theChannel to getPropAt(soundChannels, i)
- setProp(soundChannels, theChannel, [#sndType: #none, #sndName: #none, #volume: 0])
- set the volume of sound theChannel to 0
- puppetSound(theChannel, 0)
- sound stop theChannel
- exit repeat
- end if
- end repeat
- end
-
- on soundEffect whichSound, volumeDesired
- global oStoryteller
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- if voidp(volumeDesired) then
- set volumeDesired to 255
- end if
- set foundChannel to assignSound(whichSound, volumeDesired)
- if foundChannel = #none then
- put "soundEffect(" & whichSound & "): Sorry, there are no free sound channels at this time."
- reportSounds()
- exit
- else
- set channelData to getProp(soundChannels, foundChannel)
- setProp(channelData, #sndType, #effect)
- setProp(channelData, #sndName, whichSound)
- setProp(channelData, #volume, volumeDesired)
- end if
- end
-
- on suspendSounds fadeSwitch
- global oStoryteller, gSoundsSuspended
- set gSoundsSuspended to 1
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- if fadeSwitch = #fadeOut then
- repeat with fadeFactor in [0.90000000000000002, 0.75, 0.5, 0.25, 0.10000000000000001, 0.05]
- repeat with i = 1 to count(soundChannels)
- set theChannel to getPropAt(soundChannels, i)
- set the volume of sound theChannel to getProp(getProp(soundChannels, theChannel), #volume) * fadeFactor
- end repeat
- set the volume of sound 5 to the volume of sound 5 * fadeFactor
- wait(3)
- updateStage()
- end repeat
- end if
- repeat with i = 1 to count(soundChannels)
- set theChannel to getPropAt(soundChannels, i)
- set the volume of sound theChannel to 0
- puppetSound(theChannel, 0)
- sound stop theChannel
- end repeat
- set the volume of sound 5 to 0
- puppetSound(5, 0)
- sound stop 5
- updateStage()
- end
-
- on suspendCallsTest
- suspendSounds(#fadeOut)
- wait(360)
- restoreSounds(#fadeIn)
- end
-
- on restoreSounds fadeSwitch
- global oStoryteller, oPuppeteer, gSoundsSuspended
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- set soundBank to getProp(the lsForegroundData of oPuppeteer, #soundBank)
- repeat with i = 1 to count(soundChannels)
- set theChannel to getPropAt(soundChannels, i)
- set channelData to getAt(soundChannels, i)
- set mySndType to getProp(channelData, #sndType)
- if mySndType = #none then
- next repeat
- next repeat
- end if
- if mySndType = #effect then
- setProp(soundChannels, theChannel, [#sndType: #none, #sndName: #none, #volume: 0])
- next repeat
- end if
- set theCast to getProp(soundBank, getProp(channelData, #sndName))
- puppetSound(theChannel, theCast)
- end repeat
- if fadeSwitch = #fadeIn then
- set lsFadeFactors to [0.05, 0.10000000000000001, 0.25, 0.5, 0.75, 0.90000000000000002, 1.0]
- else
- set lsFadeFactors to [1.0]
- end if
- repeat with fadeFactor in lsFadeFactors
- repeat with i = 1 to count(soundChannels)
- set theChannel to getPropAt(soundChannels, i)
- set channelData to getAt(soundChannels, i)
- if getProp(channelData, #sndType) = #loop then
- set the volume of sound theChannel to getProp(channelData, #volume) * fadeFactor
- end if
- end repeat
- wait(3)
- updateStage()
- end repeat
- set gSoundsSuspended to 0
- end
-
- on reportSounds
- global oStoryteller
- set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
- put "••• Sound report •••"
- repeat with i = 1 to count(soundChannels)
- put " > Sound " & getPropAt(soundChannels, i) & ": " & getAt(soundChannels, i)
- end repeat
- put "••••••••••••••••••••"
- end
-
- on fadeOutTransit
- set STIME to the ticks
- put "fadeOutTransit() starting.."
- repeat with fadeFactor = 30.0 down to 0.0
- repeat with i = 1 to 4
- set the volume of sound i to float(the volume of sound i) * (fadeFactor / 30.0)
- updateStage()
- end repeat
- wait(4)
- updateStage()
- end repeat
- put "fadeOutTransit() done at " & the ticks - STIME
- end
-
- on transitToEdwin
- global oStorytelller, oPuppeteer, gOriginPoint
- cursorOff()
- setState(oStoryteller, #AMBERVISION, #off)
- suspendSounds(#fadeOut)
- set the loc of sprite 39 to point(320, -500) + gOriginPoint
- setState(oStoryteller, #showMontage, 1)
- updateDisplay(oPuppeteer)
- soundEffect(#toEdwin)
- pushVideo()
- wait(#videoStop)
- setState(oStoryteller, #showMontage, 2)
- killVideo()
- updateDisplay(oPuppeteer)
- pushVideo()
- wait(#videoStop)
- killVideo()
- setState(oStoryteller, #showMontage, 3)
- setTransition(oPuppeteer, #fadeIn)
- updateDisplay(oPuppeteer)
- setState(oStoryteller, #showMontage, 0)
- enterNewDomain(oStoryteller, string(#Edwin), 15)
- end
-